pp108 : Extending Custom Functions

Extending Custom Functions

This topic describes the procedure to extend the default XSLT function library provided by Cordys.

The default XSLT functions that are available with Process Platform address most data transformation requirements. However, if you need to build new functions with specific logic, you can create custom mapping functions. Modify the following files to create custom data mapping functions:

  • funcinfo.xml, which contains the mapping logic
  • functionsindex.xml, which contains information to display the function name in the mapCanvas pane
  1. On CUSP > My Applications, click (XMLStore Explorer) . XMLStore Explorer window is launched, displaying the Collection folder containing all the files and directories in the XMLStore.
  2. Expand the Collection folder. The various folders containing objects of the ISV or product, are displayed in a tree structure.
  3. Expand datatransformation folder and open the funcinfo.xmlfile and place the custom mapping logic of the function at the location shown in the following example:
    <LibFunction>. . . <Function Attr="Scientific" ID="20">
            <FunctionName>Arc Cosine</FunctionName>
            <FunctionType>JavaScript/JAVA</FunctionType>
            <Expression>fnScientificArcCosine(iNum) 
                <!-- In case of Java Function type give the class name including the package name -->
            </Expression>
            <Arguments NoOfParam="1">
                <Param DataType="Number" Required="1"/>
            </Arguments>
            <SourceCode>
                <!--your logic implementation for the function goes here See the example below --> function fnValueMapping() { var TargetValue=''; var SourceValue = fnValueMapping.arguments\[0\]; var NumberOfValuePairs = fnValueMapping.arguments.length - 1; var i = 1; while (i &amp;lt; NumberOfValuePairs) { if (fnValueMapping.arguments\[i\] == SourceValue) { TargetValue = fnValueMapping.arguments[i+1]; break; } i = i + 2; } if (TargetValue =='') { if (fnValueMapping.arguments[NumberOfValuePairs-1] == 'DEFAULT') { TargetValue = fnValueMapping.arguments\[NumberOfValuePairs\]; } } return(TargetValue) } </SourceCode>
            <Info>
                <!--Any url of the html page for help put it here .See the example below.--> /cordys/documentation/onlinehelp/mergedProjects/cordysorchestratorfordevelopers/usingvaluemapping.htm#About Value Mapping </Info>
        </Function> . . .</LibFunction>
    
  4. Save the funcinfo.xml file containing the new custom function logic.
  5. Open the funcinfoindex.xmlfile and place the group information that contains the mapping functions, at the location shown in the following example:
    <categories>. . . 
        <!-- Add the group name for your custom function, for example-->
        <eibus:menuitem submenu="stringfnsubmenu">String</eibus:menuitem>
        <!-- where, stringfnsubmenu is the Id for the context menu (listed in the next step) and String is the group name --> . . .</categories>
    
  6. Place the user interface related code at the location shown in the following example:
    <categories>
    . . . 
    </categories> 
    <functions>
    	<eibus:contextmenu id='stringfnsubmenu' style='display:none'>
    		<eibus:menuitem onclick='registerFunction(20)'>Arc Cosine</eibus:menuitem>
    		<eibus:menuitem onclick='registerFunction(21)'>LowerCase</eibus:menuitem>
    	</eibus:contextmenu>
    </functions>
  7. Save the funcinfoindex.xml file.

    The custom mapping functions are ready for implementation.

    Note: Ensure that the value you provide for registerFunction in the funcinfoindex.xml file is the same as that of the Function ID in the funcinfo.xml file. The implementation will fail if there is a mismatch.

Related tasks

Transforming Data using XSLT Functions
Creating a Content Map
Creating a Data Transformation Model